#include <iostream>
#include <cstdio>
#include <string>
#include <unistd.h>
#include <pthread.h>

void *threadrun(void *args)
{
    std::string name = (const char*)args;
    while(true)
    {
        sleep(1);
        std::cout << "我是新线程: name: " << name << ", pid: " << getpid() << std::endl;
        int a = 10;
        //a /= 0;
    }
    return nullptr;
}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, threadrun, (void*)"thread-1");

    while(true)
    {
        std::cout << "我是主线程..." << ", pid: " << getpid() << std::endl;
        sleep(1);
    }
    return 0;
}